package com.beiing.tianshuai.tianshuai.mine.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.LoginBean;
import com.beiing.tianshuai.tianshuai.mine.model.LoginModel;
import com.beiing.tianshuai.tianshuai.mine.model.LoginModelImpl;
import com.beiing.tianshuai.tianshuai.mine.view.LoginViewImpl;

/**
 * Created by Jinni on 2017/7/14 0014.
 */

public class LoginPresenter extends BasePresenter implements LoginPresenterImpl, LoginModel.OnLoginListener {

    private LoginViewImpl mLoginView;
    private LoginModelImpl mLoginModel;

    public LoginPresenter(LoginViewImpl loginView) {
        mLoginView = loginView;
        mLoginModel = new LoginModel(this);
    }

    @Override
    public void getLoginResult(String email, String pass) {
        mLoginView.showProgress();
        mLoginModel.getLoginResult(email, pass);
    }

    @Override
    public void onSuccess(LoginBean loginBean) {
        mLoginView.hideProgress();
        mLoginView.onRequestSuccess(loginBean);
    }

    @Override
    public void onError(Throwable e) {
        mLoginView.hideProgress();
        mLoginView.onRequestFailed(e);
    }
}
